package mianshi.lanxin;

import java.util.ArrayList;
import java.util.HashMap;

public class T2 {


    public static void main(String[] args) {
        int[] data = {-2,28,-2,19,-9,21,15,20,-10,-18};
        int[][] res = twoPlus(data);
        for (int i = 0; i < res.length; i++) {
            for (int j = 0; j < 2; j++) {
                System.out.println(res[i][j]);
            }
        }
    }
    public static int[][] twoPlus(int[] nums) {

        HashMap<Integer, Integer> map = new HashMap<>();
        ArrayList<int[]> list = new ArrayList<>();
        for (int i = 0; i < nums.length; i++) {
            if (map.containsKey(10 - nums[i])) {
                if (nums[i] > (10 - nums[i])) {
                    list.add(new int[]{10 - nums[i], nums[i]});
                } else {
                    list.add(new int[]{nums[i], 10 - nums[i]});
                }
            }
            map.put(nums[i], nums[i]);
        }
        int[][] res = new int[list.size()][2];
        for (int i = 0; i < list.size(); i++) {
            for (int j = 0; j < list.get(0).length; j++) {
                res[i][j] = list.get(i)[j];
            }
        }
        return res;
    }
}
